package com.xwn.provider;

import com.github.pagehelper.PageHelper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import java.util.Properties;

/**
 * 生产者provider启动类
 * @author xwn
 * @date 2019/10/24 15:57
 */
//@EnableDubboConfiguration  //用xml配置文件了,就不用这个注解了
@SpringBootApplication
@MapperScan("com.xwn.provider.mapper")
@ImportResource({"classpath:spring-dubbo.xml"})
@EntityScan(basePackages = "com.xwn.bean.entity")
@EnableJpaRepositories(basePackages = "com.xwn.provider.repository")
public class ProviderApplication {

	public static void main(String[] args) {
		SpringApplication.run(ProviderApplication.class, args);
	}


	/**
	 * 配置mybatis的分页插件pageHelper
	 **/
	@Bean
	public PageHelper pageHelper(){
		PageHelper pageHelper = new PageHelper();
		Properties properties = new Properties();
		properties.setProperty("offsetAsPageNum","true");
		properties.setProperty("rowBoundsWithCount","true");
		properties.setProperty("reasonable","true");
		//配置mysql数据库的方言
		properties.setProperty("dialect","mysql");
		pageHelper.setProperties(properties);
		return pageHelper;
	}
}
